

import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import domain.model.Bank;

import tp.ejb.AccountDao;
import tp.ejb.BankDao;
import tp.ejb.CityDao;
import tp.ejb.CustomerDao;




// creee tous les DAO et 
public class ClientTestBank {


	BankDao bdao;
	
	
	public static void main(String[] args){
		ClientTestBank tb = new ClientTestBank();
		tb.createDao();
		try {
			tb.test();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	private void test() {
		bdao.populate();
		List<Bank> banks = bdao.getList();
		for (Bank bank : banks) {
			System.out.println(bank);
		}
		
	}



	public void createDao() {
		System.out.println("creating  EjbDao");
		System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interfaces.NamingContextFactory");
		System.setProperty(Context.PROVIDER_URL, "localhost:1099");
		System.setProperty(Context.URL_PKG_PREFIXES,
				"org.jboss.naming:org.jnp.interfaces");
		try {
			bdao=(BankDao) new InitialContext().lookup("BankDaoBean/remote-tp.ejb.BankDao");

			//customerDao = (CustomerDao) new InitialContext().lookup("CustomerDaoBean/remote-tp.ejb.CustomerDao");
			//cityDao = (CityDao) new InitialContext().lookup("CityDaoBean/remote-tp.ejb.CityDao");
			//accountDao = (AccountDao) new InitialContext().lookup("AccountDaoBean/remote-tp.ejb.AccountDao");

				
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
	
	



}
